package com.yanwq.sayhi.widget;

import android.content.Context;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

import com.yanwq.sayhi.R;
import com.yanwq.sayhi.base.BaseDialog;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * 作者：yanweiqiang。
 * 日期：2016/6/16 0016。
 */
public class ChoiceDialog extends BaseDialog {
    @BindView(R.id.choice_prompt)
    TextView mTVPrompt;
    @BindView(R.id.choice_ok)
    TextView mTVOk;
    @BindView(R.id.choice_cancel)
    TextView mTVCancel;

    private String mPrompt;
    private String mOk;
    private String mCancel;
    private View.OnClickListener mOkListener;
    private View.OnClickListener mCancelListener;

    public ChoiceDialog(Context context) {
        super(context);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_choice);
        ButterKnife.bind(this);

        mTVOk.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                cancel();

                if (mOkListener != null) {
                    mOkListener.onClick(v);
                }
            }
        });

        mTVCancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                cancel();

                if (mCancelListener != null) {
                    mCancelListener.onClick(v);
                }
            }
        });
    }

    @Override
    public void show() {
        super.show();

        if (!TextUtils.isEmpty(mPrompt)) {
            mTVPrompt.setText(mPrompt);
        }

        if (!TextUtils.isEmpty(mOk)) {
            mTVOk.setText(mOk);
        }

        if (!TextUtils.isEmpty(mCancel)) {
            mTVCancel.setText(mCancel);
        }
    }

    public void setPrompt(String mPrompt) {
        this.mPrompt = mPrompt;
    }

    public void setOk(String mOk) {
        this.mOk = mOk;
    }

    public void setCancel(String mCancel) {
        this.mCancel = mCancel;
    }

    public void setOkListener(View.OnClickListener mOkListener) {
        this.mOkListener = mOkListener;
    }

    public void setCancelListener(View.OnClickListener mCancelListener) {
        this.mCancelListener = mCancelListener;
    }
}
